﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ImageUploader.domain;

namespace ImageUploader.GUI
{
    public partial class EnterPassword : Form
    {
        private List<User> myUsers;

        private List<User> faildUsers = new List<User>();


        public List<User> FailedUsers
        {
            get { return faildUsers; }
        }

        public EnterPassword(List<User> myUsers )
        {
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            InitializeComponent();
            this.myUsers = myUsers;
        }

        private void buttonNewPW_Click(object sender, EventArgs e)
        {
            StaticMethods.ExecuteMethodShowLoading(new MethodInvoker(delegate
            {
                foreach (User u in myUsers)
                    try
                    {
                        u.SetPassword(txtPasswordNew.Text);
                    }
                    catch (Exception)
                    {
                        //MessageBox.Show(ex.Message);
                        faildUsers.Add(u);
                    }
            }), this);

            this.Close();
        }

        private void button1Cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
